package com.foreknow.dao;

import com.foreknow.bean.User;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;

public class UserDaoImpl implements UserDao {
    private SqlSessionFactory sqlSessionFactory;
    //初始化SqlSessionFactory对象
    public UserDaoImpl(SqlSessionFactory sqlSessionFactory){
        this.sqlSessionFactory = sqlSessionFactory;
    }
    @Override
    public User getUserById(int id) {
        SqlSession sqlSession = sqlSessionFactory.openSession();
        User user = sqlSession.selectOne("test.getUserById",1);
        sqlSession.close();
        return user;
    }

    @Override
    public void insertUser(User user) {

    }

    @Override
    public void deleteUser(int id) {

    }
}
